import 'package:flutter/material.dart';
import 'views/hot_page.dart';
import 'views/soon_page.dart';
import 'views/top_page.dart';

class HomePage extends StatefulWidget {
  final String title;

  HomePage({Key key, this.title}) : super(key: key);

  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {

  int _currentPageIndex = 0;
  List<Widget> pages = [
    HotPage(),
    TopPage(),
    SoonPage()
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: getBodyContent(),
      bottomNavigationBar:getBottomNavgationBar()
    );
  }

  Widget getBodyContent(){
    return pages[_currentPageIndex];
  }

  Widget getBottomNavgationBar(){
    return BottomNavigationBar(
      currentIndex: _currentPageIndex,
      onTap: (index){
        setState(() {
          _currentPageIndex = index;
        });
      },
      selectedItemColor: Colors.purple,
      unselectedItemColor: Colors.grey,
      iconSize: 28,
      selectedFontSize: 14,
      unselectedFontSize: 14,
      type:BottomNavigationBarType.fixed,
      items: [
        BottomNavigationBarItem(
          icon: Icon(Icons.hot_tub),
          label: '热门电影'
        ),
        BottomNavigationBarItem(
          icon: Icon(Icons.category),
          label: 'Top250'
        ),
        BottomNavigationBarItem(
          icon: Icon(Icons.search),
          label: '即将上映'
        )
      ],
    );
  }
}
